package com.zq.mycloud.gateway.util;

import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

/**
 * @author ：zhang qiang
 * @package :com.zq.mycloud.gateway.util
 * @date ：Created in 2020/11/23 下午3:45
 * @description：
 * @modified By：
 * @version: $
 */

public class I18nUtil {
    public static String translateCode(String code, Object... args) {
        Locale locale = LocaleContextHolder.getLocale();
        ResourceBundle resourceBundle = ResourceBundle.getBundle("i18n.message", locale);
        return MessageFormat.format( resourceBundle.getString(code),args);
    }

}
